'use strict';

var fs = require('fs');
var path = require('path');
var file = 'commit_template';
var params = (process.env.GIT_PARAMS || '').split(' ');
var msg = `
#-------------------------------
# 提交格式 <type>: <message>
# type: feat | fix
# 示例: feat: 商品筛选功能开发完毕,提测
#-------------------------------
`;

if (params.length > 1) { // 有提交内容
    process.exit(0);
} else { // 无提交内容
	var Target = path.resolve(process.cwd(), params[0]);
	var existing = fs.readFileSync(Target).toString();
	fs.writeFileSync(Target, `\n\n${msg}`); 
	// fs.writeFileSync(Target, `${msg}\n\n${existing}`);
}

